﻿using System;
using System.Diagnostics;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;

namespace GauntletFramework.StateManagment.Menu
{
    public class MenuItem : DrawableGameComponent
    {
        public SpriteFont Font;
        public string Text;
        public Vector2 Center;
        public bool selected;
        public Color TextColor;
        public Color DarkTextColor { get { return new Color((byte)(TextColor.R * 0.5f), (byte)(TextColor.G * 0.5f), (byte)(TextColor.B * 0.5f), TextColor.A); } }
        public string Target;
        
        public MenuItem(SpriteFont Font, string Text, string Target, Vector2 Center)
            : base((Game)StaticGame.Game)
        {
            this.Font = Font;
            this.Text = Text;
            this.Center = Center;
            this.TextColor = new Color(1.0f, 1.0f, 1.0f);
            this.Target = Target;
            selected = false;
        }

        public MenuItem(SpriteFont Font, string Text, string Target, Vector2 Center, Color TextColor)
            : base((Game)StaticGame.Game)
        {
            this.Font = Font;
            this.Text = Text;
            this.Center = Center;
            this.TextColor = TextColor;
            this.Target = Target;
            selected = false;
        }

        public MenuItem(SpriteFont Font, string Text, string Target, Color TextColor)
            : base((Game)StaticGame.Game)
        {
            this.Font = Font;
            this.Text = Text;
            this.Center = Vector2.Zero;
            this.TextColor = TextColor;
            this.Target = Target;
            selected = false;
        }

        public MenuItem(string Text, string Target, Color TextColor)
            : base((Game)StaticGame.Game)
        {
            this.Font = MenuState.MenuFont;
            this.Text = Text;
            this.Center = Vector2.Zero;
            this.TextColor = new Color(1.0f, 1.0f, 1.0f);
            this.Target = Target;
            selected = false;
        }

        public MenuItem(string Text, string Target)
            : base((Game)StaticGame.Game)
        {
            this.Font = MenuState.MenuFont;
            this.Text = Text;
            this.Center = Vector2.Zero;
            this.TextColor = new Color(1.0f, 1.0f, 1.0f);
            this.Target = Target;
            selected = false;
        }

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            SpriteBatch sb = ((GNTMainGame)Game).SpriteBatch;

            Color CurrentColor = DarkTextColor;
            if (selected)
                CurrentColor = TextColor;
            sb.DrawString(Font, Text, Center, CurrentColor);
        }
    }
}
